/*
package com.example.demo.commons.core.robot;


import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

@Slf4j
public class WxRobotHelper {
    private static final String API = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=%s";
    private static final long DEFAULT_TIMEOUT = 1000 * 60 * 10;
    private static final Executor EXECUTOR = Executors.newSingleThreadExecutor();
    private final String key;
    private final TimedCache<Object, Object> timedCache;

    public WxRobotHelper(String key, long expirationMillisecond) {
        this.key = key;
        this.timedCache = CacheUtil.newTimedCache(expirationMillisecond);
        this.timedCache.schedulePrune(5L);
    }

    public WxRobotHelper(String key) {
        this(key, DEFAULT_TIMEOUT);
    }

    public void sendMessage(Object obj) {
        if (!this.timedCache.containsKey(obj)) {
            this.timedCache.put(obj, 1);
            EXECUTOR.execute(() -> {
                try {
                    JSONObject baseMessage = new JSONObject();
                    JSONObject message = new JSONObject();

                    for (Map.Entry<String, Object> entry : JSONUtil.parseObj(JSONUtil.toJsonStr(obj)).entrySet()) {
                        String key = entry.getKey();
                        Object value = entry.getValue();

                        if (key.equals(Constants.MSG_TYPE)) {
                            baseMessage.set(key, value);
                        } else {
                            message.set(key, value);
                        }
                    }

                    baseMessage.set(baseMessage.getStr(Constants.MSG_TYPE), message);

                    String url = String.format(API, key);
                    String body = baseMessage.toString();

                    if (log.isDebugEnabled()) {
                        log.debug("[http-request]: {}", url);
                        log.debug("[request-body]: {}", body);
                    }

                    String result = HttpRequest.post(url).body(body).execute().body();
                    if (log.isDebugEnabled()) {
                        log.debug("微信群机器人消息发送成功: url:{},msg:{},result:{}", url, body, result);
                    }
                } catch (Exception e) {
                    log.error("微信群机器人消息发送失败.key:{},msg:{}", key, obj, e);
                }
            });
        }
    }
}
*/
